<?php 
/* P3(c)

******************************************************************************
                                                                                      
                         __                                                        
                        /__)                                                       
                       /__        P3 - moving Technologie            
                        __)                                                          
                        __)                                                          
                                                                                        
                                                                                        
       Copyright 2009 by p3.co.at                                                                                 
                                                                                        
       visit www.p3.co.at to get more Informations 
       about Teriko - Betriebsdatenerfassung                                                                                 
       - it's not allowed to change this scripts
       - it's not allowed to remove this copyright-tag

       -- you can download the complete license   
          under http://www.teriko.org

 (c) by Patrik Pfaffenbauer and P3 (http://www.p3.co.at)

 | Programname: P3.Teriko
 | Authtor: P3.Verein
 | Coder: Patrik Pfaffenbauer
 | Version: 0.1

 | Change Index
 |_____________________________________________
 |                                             |
 |4.3.2010 Erstellung | Patrik Pfaffenbauer    |
 |_____________________________________________|

******************************************************************************

P3(c) */

include("_tables.php");
include("_config.php");

$site = $_GET['s'];


if($site == "member")
{
	$table = $tbluser;
	$content = new Member();
	
	if(!$content->permission->editPermission)
	{
		echo "//<script>
		alert('".$GLOBALS['lang']->GetLanguage("Permission", "noSavePermission")."');
		Redirect('index.php');";
		return;
	}
	
	if(!$content->CheckFastEditInput())
		return;
}
else if($site == "language")
{
	$table = $tbllang;
	$content = new Language();
	
	if(!$content->permission->editPermission)
	{
		echo "//<script>
		alert('".$GLOBALS['lang']->GetLanguage("Permission", "noSavePermission")."');
		Redirect('index.php');";
		return;
	}
	
	if(!$content->CheckFastEditInput())
		return;
}
else if($site == "country")
{
	$table = $tblcountry;
	$content = new Country();
	
	if(!$content->permission->editPermission)
	{
		echo "//<script>
		alert('".$GLOBALS['lang']->GetLanguage("Permission", "noSavePermission")."');
		Redirect('index.php');";
		return;
	}
	
	if(!$content->CheckFastEditInput())
		return;
	
}
else if($site == "customer")
{
	$table = $tblcustomer;
	$content = new Customer();
	
	if(!$content->permission->editPermission)
	{
		echo "//<script>
		alert('".$GLOBALS['lang']->GetLanguage("Permission", "noSavePermission")."');
		Redirect('index.php');";
		return;
	}
	
	if(!$content->CheckFastEditInput())
		return;
}
else if($site == "project")
{
	$table = $tblproject;
	$content = new Project();
	
	if(!$content->permission->editPermission)
	{
		echo "//<script>
		alert('".$GLOBALS['lang']->GetLanguage("Permission", "noSavePermission")."');
		Redirect('index.php');";
		return;
	}
	
	if(!$content->CheckFastEditInput())
		return;
}
else if($site == "task")
{
	$table = $tbljobs;
	$content = new Task();
	
	if(!$content->permission->editPermission)
	{
		echo "//<script>
		alert('".$GLOBALS['lang']->GetLanguage("Permission", "noSavePermission")."');
		Redirect('index.php');";
		return;
	}
	
	if(!$content->CheckFastEditInput())
		return;
}
else if($site == "pause")
{
	$table = $tblpause;
	$content = new Pause();
	
	if(!$content->permission->editPermission)
	{
		echo "//<script>
		alert('".$GLOBALS['lang']->GetLanguage("Permission", "noSavePermission")."');
		Redirect('index.php');";
		return;
	}
	
	if(!$content->CheckFastEditInput())
		return;
}
else
{
	echo "//<script>
	alert('".$GLOBALS['lang']->GetLanguage("Error", "FE001")."');
	Redirect('index.php');";
	return;
}

$query = "UPDATE ".$table." SET ".$_GET['field']." = '".$_GET['value']."' WHERE id='".$_GET['id']."'";
$GLOBALS['db']->Query($query);

if($_GET['action'] == "combobox")
{
	if($site == "task")
	{
		$query = $GLOBALS['db']->Query("SELECT id,name FROM ".$tblproject);
		while($line = $GLOBALS['db']->FetchRow($query))
		{
			$object[] = $line;
		}
		
		$value = $GLOBALS['db']->Fetch($GLOBALS['db']->Query("SELECT * FROM ".$tblproject." WHERE id=".$_GET['value']))->name;
	}
    else if($site == "project")
	{
		$query = $GLOBALS['db']->Query("SELECT id,name FROM ".$tblcustomer);
		while($line = $GLOBALS['db']->FetchRow($query))
		{
			$object[] = $line;
		}
		
		$value = $GLOBALS['db']->Fetch($GLOBALS['db']->Query("SELECT * FROM ".$tblcustomer." WHERE id=".$_GET['value']))->name;
	}
	
	$array = "";
	for($i = 0; $i < count($object); $i++)
	{
		$array .= implode(',', $object[$i]).";";
	}
	echo '<a href="javascript::void(0);" id="a-'.$_GET['target'].'" onmouseover="return overlib(\''.$GLOBALS['lang']->GetLanguage("Common", "fastEdit").'\');" onmouseout="return nd();" onclick="SwitchToComboBoxEdit(\''.$array.'\', \''.$_GET['target'].'\');return nd();">'.$value.'</a>';
}
else
{
	echo '<a href="javascript::void(0);" id="a-'.$_GET['target'].'" onclick="SwitchTextToEdit(\''.$_GET['target'].'\');">'.$_GET['value'].'</a>';
}
?>